package org.example.controller;

import org.example.config.R;
import org.example.service.WebSocketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("websocket")
public class WebSocketController {
    @GetMapping("/pushone")
    public void pushone(){
        WebSocketService.sendMessage("baobao","鹏宇");
    }
    @Autowired
    WebSocketService webSocketService;
    @RequestMapping("websocketAddress")
    public R websocketAddress(String x,String y){
        System.out.println(x);
        System.out.println(y);
        webSocketService.sendMessage("pushone",x+", "+y);
        return R.successed(x+", "+y);
    }

}
